<script>
//j
var e = require('./utils/core.js');
export default {
	onShow: function() {
		// this.onLaunch();
		//判断是否登录
		//this.globalData.isLogin()	
		
	},
	onHide:function(){
		
		
	},
	beforeCreate: function(){
		uni.hideTabBar({
			success(e) {
			},
			fail(r) {
			}
		});
		// #ifdef MP-WEIXIN
		uni.hideTabBar({
			complete(e) {
			}
		});
		// #endif
	},
	onLaunch: function() {
		uni.hideTabBar();
		// #ifdef MP-WEIXIN
		const updateManager = uni.getUpdateManager();
		updateManager.onCheckForUpdate(function(res) {
			// 请求完新版本信息的回调
			if (res.hasUpdate) {
				updateManager.onUpdateReady(function(res2) {
					uni.showModal({
						title: '更新提示',
						content: '发现新版本，是否重启应用?',
						success(res2) {
							if (res2.confirm) {
								// 新的版本已经下载好，调用 applyUpdate 应用新版本并重启
								updateManager.applyUpdate();
							}
						}
					});
				});
			}
		});
		// #endif

		var e = this;
		uni.getSystemInfo({
			success: function(t) {
				// #ifndef MP-WEIXIN
				t.model = t.model ? t.model : 'iPhone';
				// #endif
				'0' == t.model.indexOf('iPhone X') || '0' == t.model.indexOf('iPhone 11') ? e.globalData.setCache('isIpx', t.model) : e.globalData.setCache('isIpx', '');
			}
		});
		var t = this;
		uni.getSystemInfo({
			success: function(e) {
				uni.setStorageSync('systemInfo', e);
				var a = e.windowWidth,
					i = e.windowHeight;
				(t.globalData.ww = a), (t.globalData.hh = i);
			}
		});
	},
	globalData: {
		options: {
			id: 0
		},
		tuan_first_order: {
			success: 0
		},
		//判断是否登录,没有登录则跳到登录页,
		isLogin:function(){
			let user_token=this.getCache('user_token')
			if(user_token==''){
				uni.navigateTo({
				    url: '/pages/login/login'
				});
				
			}
		},

		checkAuth: function() {
			var self = this;
			var t = '/pages/auth/index',
				a = getCurrentPages(),
				i = a[a.length - 1];
			var n = {
				// #ifdef MP-WEIXIN
				params: i.options || null,
				// #endif
				// #ifdef H5
				params: i.$mp.query || null,
				// #endif
				// #ifdef APP-PLUS
				params: i.options || null,
				// #endif
				// #ifdef MP-TOUTIAO
				url: i.is,
				// #endif
				// #ifndef MP-TOUTIAO
				url: i.route
				// #endif
			};
			if (n.params && 'scene' in n.params) {
				var o = {},
					s = decodeURIComponent(n.params.scene)
						.split('&')
						.shift()
						.split('=');
				(o.id = s[1]), (n.params = o);
			}

			this.setCache('routeData', n);
			this.getCache('userinfo');
			// #ifdef APP-PLUS ||H5
			e.get('member', {}, function(e) {
				e.error &&
					uni.navigateTo({
						url: '/pages/login/login'
					});
			});
			// #endif
			// #ifdef MP-WEIXIN ||MP-TOUTIAO
			uni.getSetting({
				success: function(a) {
					a.authSetting['scope.userInfo']
						? e.get('member', {}, function(e) { 
								//判断新老用户是否有绑定手机
								let user = self.getCache('userinfo');
								// if (user != '') {
								// 	// #ifdef MP-WEIXIN
								// 	//抖音暂时不绑定
								// 	if (!('mobile' in user)) {
								// 		if (user.mobile == '') {
								// 			uni.navigateTo({
								// 				url: t
								// 			});
								// 			return;
								// 		}

								// 		uni.navigateTo({
								// 			url: t
								// 		});
								// 		return;
								// 	} else {
								// 		if (user.mobile == '') {
								// 			uni.navigateTo({
								// 				url: t
								// 			});
								// 			return;
								// 		}
								// 	}
								// 	// #endif
								// }
								e.error &&
									uni.navigateTo({
										url: t
									});
						  })
						: uni.navigateTo({
								url: t
						  });
				}
			});
			// #endif
			
		},
		requirejs: function(e) {
			return require('@/utils/' + e + '.js');
		},
		getConfig: function() {
			if (null !== this.api)
				return {
					api: this.api,
					approot: this.approot,
					appid: this.appid
				};
			var e = uni.getExtConfigSync();
			return (this.api = e.config.api), (this.approot = e.config.approot), (this.appid = e.config.appid), e.config;
		},
		getCache: function(e, t) {
			var a = +new Date() / 1e3,
				i = '';
			a = parseInt(a);

			// console.log("---test",a,this.appid);
			try {
				(i = uni.getStorageSync(e + this.appid)).expire > a || 0 == i.expire ? (i = i.value) : ((i = ''), this.removeCache(e));
			} catch (e) {
				i = void 0 === t ? '' : t;
			}

			return (i = i || '');
		},
		setCache: function(e, t, a) {
			var i = +new Date() / 1e3,
				n = !0,
				o = {
					expire: a ? i + parseInt(a) : 0,
					value: t
				};

			try {
				uni.setStorageSync(e + this.appid, o);
			} catch (e) {
				n = !1;
			}

			return n;
		},
		removeCache: function(e) {
			var t = !0;

			try {
				uni.removeStorageSync(e + this.appid);
			} catch (e) {
				t = !1;
			}

			return t;
		},
		close: function() {
			(this.globalDataClose.flag = !0),
				uni.reLaunch({
					url: '/pages/index/index'
				});
		},
		getSet: function() {
			var t = this;
			'' == t.getCache('cacheset') &&
				setTimeout(function() {
					var a = t.getCache('cacheset');
					e.get(
						'cacheset',
						{
							version: a.version
						},
						function(e) {
							e.update && t.setCache('cacheset', e.data);
						}
					);
				}, 10);
		},
		url: function(e) {
			e = e || {};
			var t,
				a,
				i = {},
				n = this.getCache('usermid');

			for (var o in ((t = e.mid || ''), (a = e.merchid || ''), n)) void 0 !== n[o] && (i[o] = n[o]);

			'' != n ? (('' != n.mid && void 0 !== n.mid) || (i.mid = t), ('' != n.merchid && void 0 !== n.merchid) || (i.merchid = a)) : ((i.mid = t), (i.merchid = a)),
				this.setCache('usermid', i);
		},
		impower: function(e, t, a) {
			// #ifdef MP-WEIXIN
			uni.getSetting({
				success: function(i) {
					i.authSetting['scope.' + e] ||
						uni.showModal({
							title: '用户未授权',
							content: '您点击了拒绝授权，暂时无法' + t + '，点击去设置可重新获取授权喔~',
							confirmText: '去设置',
							success: function(e) {
								e.confirm
									? uni.openSetting({
											success: function(e) {}
									  })
									: 'route' == a
									? uni.switchTab({
											url: '/pages/index/index'
									  })
									: 'details' == a ||
									  uni.navigateTo({
											url: '/pages/index/index'
									  });
							}
						});
				}
			});
			// #endif
		},
		globalDataClose: {
			flag: !1
		},
		globalData: {
			version:1,
			appid: 'wxc9a0933fb19296d8',
			api: 'https://weixin.jxshops.cn/app/jxshops.php?m=z&do=mobile',
			approot: 'https://weixin.jxshops.cn/newstatic/appstatic/',
			aid: 0
		},
		params: {},
		list: [],
		//鲸选-v2正式
		// appid: 'wx7e0ea5d13177b6be',
		// api: 'https://weixin.jxshops.cn/app/jxshops_api.php?i=16',
		// approot: 'https://weixin.jxshops.cn/addons/ewei_shopv2/',
		//鲸选-v2
		// appid: "wx7e0ea5d13177b6be",
		api: "https://c1.91zjj.cn/app/jxshops_api.php?i=16",
		//api: "http://192.168.1.6/app/ewei_shopv2_api.php?i=1",
		//api:'http://192.168.1.6/app/index.php?i=1&c=entry&m=ewei_shopv2&do=mobile&r=',
		// approot: "https://c1.91zjj.cn/addons/ewei_shopv2/",
		// appid: "wx7e0ea5d13177b6be",
		// api: "https://www.jxshops.com/app/jxshops_api.php?i=16",
		// approot: "https://www.jxshops.com/addons/ewei_shopv2/",
		//OAO-v1
		// appid: "wx58efc91d688e7699",
		// api: "https://uni.91zjj.cn/app/jxshops_api.php?i=16",
		// approot: "https://uni.91zjj.cn/addons/ewei_shopv2/",
		//鲸选-v3
		//appid: "wxc9a0933fb19296d8",
		//api: "https://weixin.jxshops.cn/app/jxshops_api.php?i=16",
		// api: "http://192.168.1.9/app/ewei_shopv2_api.php?i=1",
		approot: "https://wx.91zjj.cn/addons/youyouji/",
		autoHost:"https://wx.91zjj.cn/addons/youyouji/",
		qiNiu:'http://qiniu.91zjj.cn',
		//OAO-v3
		// userinfo_openid58efc91d688e7699 {"type":"object","data":{"expire":0,"value":"ohr2B4k5fmtStetfPzeRjBHgPdss"}}
		// appid: 'wx58efc91d688e7699',
		// api: 'https://x1.91zjj.cn/app/jxshops_api.php?i=16',
		// approot: 'https://x1.91zjj.cn/addons/ewei_shopv2/',
		//几米堂
		appid: 'wx2c02ab8f845e373c',
		// api: 'https://x1.91zjj.cn/app/jxshops_api.php?i=14',
		// approot: 'https://x1.91zjj.cn/addons/ewei_shopv2/',
		userInfo: null,
		isgoods: true
	},
	methods: {}
};
</script>

<style lang="scss">
/* 行为相关颜色 */
$uni-color-primary: #007aff;
$uni-color-success: #4cd964;
$uni-color-warning: #f0ad4e;
$uni-color-error: #dd524d;

/* 文字基本颜色 */
$uni-text-color: #333; //基本色
$uni-text-color-inverse: #fff; //反色
$uni-text-color-grey: #ccc; //辅助灰色，如加载更多的提示信息
$uni-text-color-placeholder: #808080;
$uni-text-color-disable: #c0c0c0;

/* 背景颜色 */
$uni-bg-color: #ffffff;
$uni-bg-color-grey: #f8f8f8;
$uni-bg-color-hover: #f1f1f1; //点击状态颜色
$uni-bg-color-mask: rgba(0, 0, 0, 0.4); //遮罩颜色

/* 边框颜色 */
$uni-border-color: #e5e5e5;

/* 尺寸变量 */

/* 文字尺寸 */
$uni-font-size-sm: 20rpx;
$uni-font-size-base: 24rpx;
$uni-font-size-lg: 28rpx;

/* 图片尺寸 */
$uni-img-size-sm: 40rpx;
$uni-img-size-base: 52rpx;
$uni-img-size-lg: 80rpx;

/* Border Radius */
$uni-border-radius-sm: 4rpx;
$uni-border-radius-base: 6rpx;
$uni-border-radius-lg: 12rpx;
$uni-border-radius-circle: 50%;

/* 水平间距 */
$uni-spacing-row-sm: 10px;
$uni-spacing-row-base: 20rpx;
$uni-spacing-row-lg: 30rpx;

/* 垂直间距 */
$uni-spacing-col-sm: 8rpx;
$uni-spacing-col-base: 16rpx;
$uni-spacing-col-lg: 24rpx;

/* 透明度 */
$uni-opacity-disabled: 0.3; // 组件禁用态的透明度

/* 文章场景相关 */
$uni-color-title: #2c405a; // 文章标题颜色
$uni-font-size-title: 40rpx;
$uni-color-subtitle: #555555; // 二级标题颜色
$uni-font-size-subtitle: 36rpx;
$uni-color-paragraph: #3f536e; // 文章段落颜色
$uni-font-size-paragraph: 30rpx;

/* 自定義 c=customer */

page {
	font-size: $uni-font-size-base !important;
	line-height: 32upx !important;
}
.fui-list-icon {
	padding-right: 20upx;
}
.fui-list-inner .text {
	font-size: 24upx !important;
}
.newbtn{
	height: 72upx;
	line-height: 72upx;
	padding: 0;
	text-align: center;
}
.btn {
	text-align: center !important;
	font-size: 28upx;
}

.btn-radius {
	border-radius: 10upx !important;
}
.fui-modal.goodslist .option-picker .fui-navbar .cartbtn {
	color: #fff !important;
}
.btn-default {
	background: linear-gradient(to right, #e3e3e3 0%, #e2e2e2 100%, #e2e2e2 100%) !important;
	box-shadow: 2px 2px 7px #f3f3f3 !important;
	color: #999 !important;
}

.btn-danger {
	background: #9da9b9 !important;
	color: #fff !important;
}

.btn-default-o {
	background: #9da9b9 !important;
	color: #fff !important;
}

.btn-danger-o {
	background: #9da9b9 !important;
	color: #fff !important;
}
input {
	font-size: 24upx;
}
button:after {
	border: 0upx solid #fff;
}
.uni-swiper-dot-active,
.swiper-dot-active {
	background-color: #fff1d6;
}
/* 自定義 */
</style>

<style>
@import './app.css';
</style>
